﻿using System.Windows;

namespace Rio.Framework.Pages.Helpers.DragDrop
{
    public partial class RowReorderBehavior : DependencyObject
    {
        public static Style GetDragCueStyle(DependencyObject obj)
        {
            return (Style)obj.GetValue(DragCueStyleProperty);
        }

        public static void SetDragCueStyle(DependencyObject obj, Style value)
        {
            obj.SetValue(DragCueStyleProperty, value);
        }

        // Using a DependencyProperty as the backing store for DragCueStyle.  This enables animation, styling, binding, etc...
        public static readonly DependencyProperty DragCueStyleProperty =
            DependencyProperty.RegisterAttached("DragCueStyle", typeof(Style), typeof(RowReorderBehavior), new System.Windows.PropertyMetadata(OnDragCueStylePropertyChanged));

        private static void OnDragCueStylePropertyChanged(DependencyObject sender, DependencyPropertyChangedEventArgs args)
        {
            RowReorderBehavior rowReorder = (RowReorderBehavior)sender;

            if (rowReorder.dragCue != null)
                rowReorder.dragCue.Style = GetDragCueStyle(rowReorder.AssociatedObject);
        }

        private static void OnDragCueActionContentTemplatePropertyChanged(DependencyObject sender, DependencyPropertyChangedEventArgs args)
        {
            RowReorderBehavior rowReorder = (RowReorderBehavior)sender;

            if (rowReorder.dragCue != null)
                rowReorder.dragCue.DragActionContentTemplate = GetDragCueActionContentTemplate(rowReorder.AssociatedObject);
        }

        public static DataTemplate GetDragCueActionContentTemplate(DependencyObject obj)
        {
            return (DataTemplate)obj.GetValue(DragCueActionContentTemplateProperty);
        }

        public static void SetDragCueActionContentTemplate(DependencyObject obj, DataTemplate value)
        {
            obj.SetValue(DragCueActionContentTemplateProperty, value);
        }

        // Using a DependencyProperty as the backing store for DragCueActionContentTemplate.  This enables animation, styling, binding, etc...
        public static readonly DependencyProperty DragCueActionContentTemplateProperty =
            DependencyProperty.RegisterAttached("DragCueActionContentTemplate", typeof(DataTemplate), typeof(RowReorderBehavior), new System.Windows.PropertyMetadata(null, OnDragCueActionContentTemplatePropertyChanged));

        public static DataTemplate GetDragCueTooltipContentTemplate(DependencyObject obj)
        {
            return (DataTemplate)obj.GetValue(DragCueTooltipContentTemplateProperty);
        }

        public static void SetDragCueTooltipContentTemplate(DependencyObject obj, DataTemplate value)
        {
            obj.SetValue(DragCueTooltipContentTemplateProperty, value);
        }

        // Using a DependencyProperty as the backing store for DragCueTooltipContentTemplate.  This enables animation, styling, binding, etc...
        public static readonly DependencyProperty DragCueTooltipContentTemplateProperty =
            DependencyProperty.RegisterAttached("DragCueTooltipContentTemplate", typeof(DataTemplate),
            typeof(RowReorderBehavior), new System.Windows.PropertyMetadata(null, OnDragCueTooltipContentTemplatePropertyChanged));

        private static void OnDragCueTooltipContentTemplatePropertyChanged(DependencyObject sender, DependencyPropertyChangedEventArgs args)
        {
            RowReorderBehavior rowReorder = (RowReorderBehavior)sender;

            if (rowReorder.dragCue != null)
                rowReorder.dragCue.DragTooltipContentTemplate = GetDragCueTooltipContentTemplate(rowReorder.AssociatedObject);
        }
    }
}
